package cn.gson.springmvc.model.pojos;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Objects;

@Entity
public class User {
    private int userId;
    private String userName;
    private String userPwd;
    private String userSex;
    private String userPhone;
    private String userAddress;
    private Timestamp userDatetime;
    private Integer userIsshow;
    private String userHead;
    private Collection<Hospitalization> hospitalizationsByUserId;
    private Ordered orderedByUserId;
    private Collection<Presc> prescsByUserId;
    private Collection<Scheduling> schedulingsByUserId;
    private Veg vegByVegId;
    private Dept deptByDeptId;
    private Division divisionByDivisionId;

    @Id
    @Column(name = "user_id", nullable = false)
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "user_name", nullable = true, length = 30)
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Basic
    @Column(name = "user_pwd", nullable = true, length = 30)
    public String getUserPwd() {
        return userPwd;
    }

    public void setUserPwd(String userPwd) {
        this.userPwd = userPwd;
    }

    @Basic
    @Column(name = "user_sex", nullable = true, length = 30)
    public String getUserSex() {
        return userSex;
    }

    public void setUserSex(String userSex) {
        this.userSex = userSex;
    }

    @Basic
    @Column(name = "user_phone", nullable = true, length = 30)
    public String getUserPhone() {
        return userPhone;
    }

    public void setUserPhone(String userPhone) {
        this.userPhone = userPhone;
    }

    @Basic
    @Column(name = "user_address", nullable = true, length = 30)
    public String getUserAddress() {
        return userAddress;
    }

    public void setUserAddress(String userAddress) {
        this.userAddress = userAddress;
    }

    @Basic
    @Column(name = "user_datetime", nullable = true)
    public Timestamp getUserDatetime() {
        return userDatetime;
    }

    public void setUserDatetime(Timestamp userDatetime) {
        this.userDatetime = userDatetime;
    }

    @Basic
    @Column(name = "user_isshow", nullable = true)
    public Integer getUserIsshow() {
        return userIsshow;
    }

    public void setUserIsshow(Integer userIsshow) {
        this.userIsshow = userIsshow;
    }

    @Basic
    @Column(name = "user_head", nullable = true, length = 255)
    public String getUserHead() {
        return userHead;
    }

    public void setUserHead(String userHead) {
        this.userHead = userHead;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return userId == user.userId &&
                Objects.equals(userName, user.userName) &&
                Objects.equals(userPwd, user.userPwd) &&
                Objects.equals(userSex, user.userSex) &&
                Objects.equals(userPhone, user.userPhone) &&
                Objects.equals(userAddress, user.userAddress) &&
                Objects.equals(userDatetime, user.userDatetime) &&
                Objects.equals(userIsshow, user.userIsshow) &&
                Objects.equals(userHead, user.userHead);
    }

    @Override
    public int hashCode() {
        return Objects.hash(userId, userName, userPwd, userSex, userPhone, userAddress, userDatetime, userIsshow, userHead);
    }



    @OneToMany(mappedBy = "userByUserId")
    public Collection<Hospitalization> getHospitalizationsByUserId() {
        return hospitalizationsByUserId;
    }

    public void setHospitalizationsByUserId(Collection<Hospitalization> hospitalizationsByUserId) {
        this.hospitalizationsByUserId = hospitalizationsByUserId;
    }



    @OneToOne(mappedBy = "userByUserId")
    public Ordered getOrderedByUserId() {
        return orderedByUserId;
    }

    public void setOrderedByUserId(Ordered orderedByUserId) {
        this.orderedByUserId = orderedByUserId;
    }

    @OneToMany(mappedBy = "userByUserId")
    public Collection<Presc> getPrescsByUserId() {
        return prescsByUserId;
    }

    public void setPrescsByUserId(Collection<Presc> prescsByUserId) {
        this.prescsByUserId = prescsByUserId;
    }

    @OneToMany(mappedBy = "userByUserId")
    public Collection<Scheduling> getSchedulingsByUserId() {
        return schedulingsByUserId;
    }

    public void setSchedulingsByUserId(Collection<Scheduling> schedulingsByUserId) {
        this.schedulingsByUserId = schedulingsByUserId;
    }

    @ManyToOne
    @JoinColumn(name = "veg_id", referencedColumnName = "veg_id")
    public Veg getVegByVegId() {
        return vegByVegId;
    }

    public void setVegByVegId(Veg vegByVegId) {
        this.vegByVegId = vegByVegId;
    }

    @ManyToOne
    @JoinColumn(name = "dept_id", referencedColumnName = "dept_id")
    public Dept getDeptByDeptId() {
        return deptByDeptId;
    }

    public void setDeptByDeptId(Dept deptByDeptId) {
        this.deptByDeptId = deptByDeptId;
    }


    @ManyToOne
    @JoinColumn(name = "division_id", referencedColumnName = "division_id")
    public Division getDivisionByDivisionId() {
        return divisionByDivisionId;
    }

    public void setDivisionByDivisionId(Division divisionByDivisionId) {
        this.divisionByDivisionId = divisionByDivisionId;
    }

}
